package websocket

import (
	"context"
	"websocket/internal/consts"
	"websocket/utility"
)

type wSysFunc struct {
}

var (
	insSysFunc = wSysFunc{}
)

func SysFunc() *wSysFunc {
	return &insSysFunc
}

func (s *wSysFunc) Ping(ctx context.Context, work *consts.WebsocketWorkContext) (res *consts.WebsocketWorkRes, err error) {
	res = utility.Common.BuildWebsocketRes(ctx, work)
	res.Cmd = consts.WebsocketCmdSysPong
	return
}

func (s *wSysFunc) Pong(ctx context.Context, work *consts.WebsocketWorkContext) (res *consts.WebsocketWorkRes, err error) {
	res = utility.Common.BuildWebsocketRes(ctx, work)
	res.Cmd = consts.WebsocketCmdSysPing
	return
}

func (s *wSysFunc) Panic(ctx context.Context, work *consts.WebsocketWorkContext) (res *consts.WebsocketWorkRes, err error) {
	res = utility.Common.BuildWebsocketRes(ctx, work)
	panic("panic test")
	return
}
